package com.ccc.dingtalk.util;

/**
 * 新版服务端工具类（本项目暂使用的是旧版）
 *
 * @author superC
 * @version 2.0.0
 * @date 2023/8/7
 */

//@Component
public class Dingtalk2Util {
    /*protected static final Logger logger = LoggerFactory.getLogger(Dingtalk2Util.class);

    @Autowired
    private DingtalkProperties dingtalkProperties;

    *//**
     * 使用 Token 初始化账号Client
     *
     * @return Client
     * @throws Exception
     *//*
    public com.aliyun.dingtalkoauth2_1_0.Client createClient() throws Exception {
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
        config.protocol = "https";
        config.regionId = "central";
        return new com.aliyun.dingtalkoauth2_1_0.Client(config);
    }

    *//**
     * 获取access_token
     *
     * @return token封装对象
     *//*
    public GetAccessTokenResponseBody getAccessToken() throws Exception {
        com.aliyun.dingtalkoauth2_1_0.Client client = createClient();
        com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest getAccessTokenRequest = new com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest()
                .setAppKey(dingtalkProperties.getAppKey())
                .setAppSecret(dingtalkProperties.getAppSecret());
        try {
            GetAccessTokenResponse tokenResponse = client.getAccessToken(getAccessTokenRequest);
            return tokenResponse.body;
        } catch (TeaException err) {
            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                // err 中含有 code 和 message 属性，可帮助开发定位问题
                logger.error("【获取钉钉token】\r\n异常记录：", err);
            }

        } catch (Exception _err) {
            TeaException err = new TeaException(_err.getMessage(), _err);
            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                // err 中含有 code 和 message 属性，可帮助开发定位问题
                logger.error("【获取钉钉token】\r\n异常记录：", err);
            }

        }
        return null;
    }*/

}
